package com.armrest.screen

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import androidx.recyclerview.widget.RecyclerView
import com.armrest.screen.provider.SgravityModelProvider
import com.armrest.screen.provider.WindowModelProvider
import com.gyf.immersionbar.ImmersionBar
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {
    val  adapter by lazy {
        HomeAdapter().apply {
            (getItemProvider(1) as SgravityModelProvider)//重力 ture 关闭 false 打开
                .itemClick={
//                 Toast.makeText(this@MainActivity,if(it) "已关闭重力" else "已打开重力",Toast.LENGTH_LONG).show()
            }
            (getItemProvider(2) as WindowModelProvider)//车窗 ture 关闭 false 打开
               .itemClick = {
//                 Toast.makeText(this@MainActivity,if(it) "已关闭车窗" else "已打开车窗",Toast.LENGTH_LONG).show()
             }
            (getItemProvider(2) as WindowModelProvider)//天窗 ture 关闭 false 打开
               .itemWindowClick = {
//                 Toast.makeText(this@MainActivity,if(it) "已关闭天窗" else "已打开天窗",Toast.LENGTH_LONG).show()
             }
            this.addData(HomeMenuModel(1))
            this.addData(HomeMenuModel(2))
            this.addData(HomeMenuModel(3))
            this.addData(HomeMenuModel(4))
            this.addData(HomeMenuModel(5))
            this.addData(HomeMenuModel(6))
        }
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        ImmersionBar.with(this).transparentStatusBar()  //透明状态栏，不写默认透明色
            .transparentNavigationBar()
            .autoDarkModeEnable(true).transparentBar().init()
        page_view.layoutManager=LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
        page_view.adapter=adapter
        var helper= PagerSnapHelper()
        helper.attachToRecyclerView(page_view)
    }
}